<Snippet><Contents1><script language="JavaScript">
var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var monthNums = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
var now = new Date();
// Display date in format Month DD, YYYY
document.write(monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getYear());
document.write("<br>");
// Display date in format MM-DD-YYYY
document.write(monthNums[now.getMonth()] + "-" + now.getDate() + "-" + now.getYear());
document.write("<br>");
// Display date in format DD.MM.YYYY
document.write(now.getDate() + "." + monthNums[now.getMonth()] + "." + now.getYear());
</script></Contents1>
<Snippet><Contents1><script language="JavaScript" type="text/javascript">
<!--
document.write("This web page is located @ " + document.location);
// -->
</script></Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Show Page Location</Title>
</Snippet>
<Snippet><Contents1><a href="javascript:self.close()">Close This Window</a></Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Close Window Link</Title>
</Snippet>
<Snippet><Contents1><script language="JavaScript">
<!-- This Script And Over 400 Others Found At --!>
<!-- Java City 2000 http://www.jc2k.com --!>
<!--
//The page they go to if they get it right.
var goodURL = "correct.html";
alert("To access the following document, you must pass a "
+ "members-only, authorization test.\n \n At the appropriate "
+ "time, enter in your username and password.");
var username = prompt("Enter in your username","");
var password = prompt("Enter in your password","");
if (username == null || password == null)
{
alert("Authentication failed.")
history.back();
}
else
{
var combo = username + password
var total = combo.toLowerCase()
//This next line is where you can add usernames and passwords.
if (total == "mynamemypass" || total == "name2pass2" || total == "josh1help1")
{
alert("You passed authentication. Come right in!");
location = goodURL;
}
else
{
alert("Authentication failed.");
history.back();
}
}
//-->
</script></Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Password Protection</Title>
</Snippet>
<Snippet><Contents1><script language="JavaScript">
document.write("Hello, ");
document.write(prompt("What is your Name?","Enter Name"));
document.write(". Welcome to My Website!");
</script></Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Prompt Sample</Title>
</Snippet>
<Snippet><Contents1><!-- Page body must have following OnLoad handler -->
<body onload="if (self != top) top.location = self.location"></Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Get Out Of Frames</Title>
</Snippet>
</Snippets>
<SubFolders></SubFolders>
<Title>JavaScript Instant Scripts</Title>
</Folder>
<Folder><Expanded>False</Expanded>
<Snippets><Snippet><Contents1>a:link {
color: Blue
}
a:visited {
color: Purple
}
a:active {
color: Red
}
a:hover {
color: Red
}</Contents1>
<Snippet><Contents1>// uncomment next line if running on PHP below 4.2.0
// srand((double)microtime()*1234567);
$random = rand(0, 100); // between 0 and 100 inclusive</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Random Number</Title>
</Snippet>
</Snippets>
<SubFolders><Folder><Expanded>False</Expanded>
<Snippets><Snippet><Contents1>mail("nobody@example.com", "My Subject", "Line 1\nLine 2\nLine 3");</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Send Basic Message</Title>
</Snippet>
<Snippet><Contents1>// Some data for the message
$mailTo = "nobody@example.com";
$mailFrom = "someone@example.com";
$mailFromName = "Some One";
$mailSubject = "Your Subject";
$mailMessage = "Your message.";
// Send mail
mail($mailTo, $mailSubject, $mailMessage, "From: $mailFromName <$mailFrom>\r\n");</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Send Simple Message</Title>
</Snippet>
<Snippet><Contents1>// Recipients
$mailTo = "one@example.com, two@example.com"; // note the comma
// Copies
$mailCc = "three@example.com";
$mailBcc = "four@example.com";
// From
$mailFrom = "someone@example.com";
$mailFromName = "Some One";
// Reply address
$mailReplyTo = "noone@example.com";
// Message subject and contents
$mailSubject = "Your Subject";
$mailMessage = "Your message.\n\nYour Signature";
// Text message charset
$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)
// Create headres for mail() function
$headers = "Content-type: text/html; charset=$mailCharset\r\n";
$headers .= "From: $mailFromName <$mailFrom>\r\n";
$headers .= "Reply-To: $mailReplyTo\r\n";
$headers .= "Cc: $mailCc\r\n";
$headers .= "Bcc: $mailBcc\r\n";
// Send mail
mail($mailTo, $mailSubject, $mailMessage, $headers);
</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Send Complex Message</Title>
</Snippet>
</Snippets>
<SubFolders></SubFolders>
<Title>Mail</Title>
</Folder>
<Folder><Expanded>False</Expanded>
<Snippets><Snippet><Contents1>// Select just one format from all the examples
$today = date("F j, Y, g:i a"); // e.g. March 10, 2001, 5:16 pm
$today = date("m/d/y"); // e.g. 03/10/04
$today = date("j, n, Y"); // e.g. 10, 3, 2001
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // e.g. it is the 10th day.
$today = date("D M j G:i:s T Y"); // e.g. Sat Mar 10 15:16:08 MST 2001
$today = date("H:i:s"); // e.g. 17:16:17
print $today;
// See PHP manual for more</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Display Current Date</Title>
</Snippet>
<Snippet><Contents1>// Display past and future dates
// Just add or substract days, months or years
$tomorrow = mktime (0,0,0,date("m"), date("d")+1, date("Y"));
$lastmonth = mktime (0,0,0,date("m")-1, date("d"), date("Y"));
$nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
// Now you can use date values with date() function
echo "Tomorrow is " . date("m/d/Y", $tomorrow) . "</br>";
echo "Before one month it was " . date("m/d/Y", $lastmonth) . "</br>";
echo "After a year it will be " . date("m/d/Y", $nextyear) . "</br>";</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Past and Future Date</Title>
</Snippet>
<Snippet><Contents1></Contents1>
<Contents2>/*
Simple Calendar
by Karlis Blumentals (www.blumentals.net)
Displays a calendar, one month at a time.
Selected date is passed as parameter day=yyyy-mm-dd
e.g. myscript.php?day=2004-10-30
*/
// date ok flag
$dateok = false;
// parse parameter
if (isset($GLOBALS['day'])) {
list($yr, $mo, $da) = explode('-', $_GET['day']);
$yr = intval($yr);
$mo = intval($mo);
$da = intval($da);
if (checkdate($mo, $da, $yr)) $dateok = true;
}
// if invalid date selected then selected date = today
if (!$dateok) {
$mo = date('m');
$da = date('d');
$yr = date('Y');
}
$offset = date('w', mktime(0,0,0,$mo,1,$yr));
// we must have a value in range 1..7
if ($offset == 0) $offset = 7;
// days in month
$nd = date('d', mktime(0,0,0,$mo+1,0,$yr));
// days array
$days = array();
// reset array
for ($i=0;$i<=42;$i++) $days[$i]['out']= ' ';
// fill days array
// valid days contain data, invalid days are left blank
$j=1;
for ($i=$offset;$i<=($offset+$nd-1);$i++) {
$day = $j++;
$date = $yr.'-'.$mo.'-'.$day;
$days[$i]['out']= '<a href="?day='.$date.'">'.$day.'</a>';
$days[$i]['dat']= $date;
}
// output table
echo('<table border="1" cellpadding="3" cellspacing="0" width="200">');
echo('<tr>');
echo('<td colspan="1" align="center" class="linkbar"><a href="?day='.date('Y-m-d', mktime(0,0,0,$mo,$da,$yr-1)).'">«</a></td>');
echo('<td colspan="5" align="center" class="linkbar"><p class="calendar">'.$yr.'</p></td>');
echo('<td colspan="1" align="center" class="linkbar"><a href="?day='.date('Y-m-d', mktime(0,0,0,$mo,$da,$yr+1)).'">»</a></td>');
echo('</tr>'."\n");
echo('<tr>');
echo('<td colspan="1" align="center" class="linkbar2"><a href="?day='.date('Y-m-d', mktime(0,0,0,$mo,0,$yr)).'">«</a></td>');
echo('<td colspan="5" align="center" class="linkbar2"><p class="calendar">'.date('F', mktime(0,0,0,$mo,$da,$yr)).'</p></td>');
echo('<td colspan="1" align="center" class="linkbar2"><a href="?day='.date('Y-m-d', mktime(0,0,0,$mo+1,1,$yr)).'">»</a></td>');
echo('</tr>'."\n");
$cntr = 1; // day printing counter
for ($i=1;$i<=6;$i++) {
echo('<tr>');
for ($j=1;$j<=7;$j++) {
$curr = $cntr++;
if ($days[$curr]['dat'] == $yr.'-'.$mo.'-'.$da) $style = 'bold'; else $style = 'normal';
echo('<td width="14%" style="font-weight: '.$style.'">'.$days[$curr]['out'].'</td>'."\n");
}
echo('</tr>'."\n");
}
echo('</table>');</Contents2>
<ShCut>0</ShCut>
<Title>Calendar</Title>
</Snippet>
</Snippets>
<SubFolders></SubFolders>
<Title>Date and Time</Title>
</Folder>
<Folder><Expanded>False</Expanded>
<Snippets><Snippet><Contents1>// Get image dimensions
$myimg = "http://www.google.com/images/logo.gif"; // your image file
list($width, $height, $type, $attr) = getimagesize($myimg);
echo "Image size: $width x $height";
echo "<br /><img src=\"$myimg\" $attr />";</Contents1>
<Contents2></Contents2>
<ShCut>0</ShCut>
<Title>Get Image Size</Title>
</Snippet>
</Snippets>
<SubFolders></SubFolders>
<Title>Images</Title>
</Folder>
<Folder><Expanded>False</Expanded>
<Snippets><Snippet><Contents1></Contents1>
<Contents2> // List Directory Contents
$path = "test/"; // full path to the folder
$url = "http://www.example.com/test/"; // URL to files
// you must add slash (/) at the end
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == "..")
continue;
if (is_file($path.$file)) {
echo "<a href=\"$url$file\">$file</a><br />";
} else {
echo "$file [DIR]<br />";
}
}
// Close
closedir($dir_handle);</Contents2>
<ShCut>0</ShCut>
<Title>List Directory Contents</Title>
</Snippet>
<Snippet><Contents1></Contents1>
<Contents2>// enter valid full or relative file path or URL
$myTextFile = 'data/yourfile.txt';
if (file_exists($myTextFile)) {
$text = implode('', file($myTextFile));
} else {
echo("File $mytextfile not found!");
$text = '';
} // $text now contains file contents, if any</Contents2>
<ShCut>0</ShCut>
<Title>Read Text from File</Title>
</Snippet>
<Snippet><Contents1></Contents1>
<Contents2>// Save text to file
$inputString = "This is the first line.\nThis is the seconds line.";
// On Windows platformu, use \n\r instead of \n
$fp = fopen( "data/yourfile.txt" , "w" );
fwrite($fp, $inputString);
fclose($fp);</Contents2>